<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>类</title>
		<script>
		  class Animal{ 
			  constructor(a,b,age=10) {
			      this.name=a;
				  this.sex=b;
				  this.age=age;
			  }
			  show(){
				  alert("这个动物的名字叫"+this.name+",性别是"+this.sex+",今年是"+this.age+"岁了");
			  }
			  //没有重载的概念
			  incrAge(a=1){
				  this.age+=a;
			  }
			  geAge(){
				  return this.age;
			  }
		  }
		  class Dog extends Animal{
			  constructor(name,sex,age,type){
				  super(name,sex,age);
				  this.type=type;
			  }
			  zhua(n){
				  if(!(n instanceof Mouse)){
					  alert("不是老鼠")
					  return;
				  }
				  alert(this.name+"抓住了"+n);
			  }
			  //重写
			  show(){
				   super.show();
				  alert("类别是"+this.type);
				  //alert(c)
			  }
			  toString(){
				  return this.name+","+this.age+","+this.type;
			  }
		  }
		  class Mouse{
			  
		  }
		  var an=new Animal("小五花","公",3);
		  //an.show();
		  // an.incrAge();
		  // an.show();
		  // an.incrAge(4);
		  // an.show();
		  var dog=new Dog("旺财","公",13,"田园犬");
		  alert(dog);
		  dog.show();
		  dog.zhua("老母鸡");
		</script>
	</head>
	<body>
	</body>
</html>
